/*
 *@Description: 用户token模型
 *@Author: panlua
 *@Date: 2019-05-23 11:36:30
*/
const mongoose = require('mongoose')
const Schema = mongoose.Schema

const tokenSchema = new Schema({
  uid: { // 用户Id
    type: String,
    required: true,
  },
  token: { // 用户token，用户id+登陆时间+用户ip+随机数  MD5加密
    type: String,
    required: true
  },
  createTime: { // 登录时间
    type: Date,
    default: Date.now
  },
  expiresTime: { // 过期时间
    type: Date,
    default: Date.now
  }
})

module.exports = mongoose.model('Token', tokenSchema, 'token')